package com.opencv.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author: zj.zhong
 * @Description:
 * @Date: Created in 2021/7/21 16:31
 */
@Configuration
public class GlobalConfiguration {

    @Value("${opencv.global.worker-id:1}")
    private int workerId;
    @Value("${opencv.global.data-center-id:1}")
    private int dataCenterId;

    private static final Logger LOGGER = LoggerFactory.getLogger(GlobalConfiguration.class);

    /***
     * 机器ID
     */
    public static int WORKER_ID=1;

    /***
     * 数据中心ID
     */
    public static int DATA_CENTER_ID=1;

    @PostConstruct
    public void setWorkerIdPost() {
        GlobalConfiguration.WORKER_ID = workerId;
        GlobalConfiguration.DATA_CENTER_ID = dataCenterId;
        LOGGER.info(String.format("Server running with [DATA_CENTER_ID]=%d [WORKER_ID]=%d", DATA_CENTER_ID, WORKER_ID));
    }
}
